home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_objc.idb / usr / freeware / include / objcrt / objcrt.h.z / objcrt.h
Encoding:
C/C++ Source or Header  |  1999-07-16  |  4.2 KB  |  162 lines

  1.  
  2. /*
  3.  * Portable Object Compiler (c) 1997,98,99.  All Rights Reserved.
  4.  * $Id: objcrt.h,v 1.12 1999/06/23 19:22:09 stes Exp $
  5.  */
  6.  
  7. /*
  8.  * This library is free software; you can redistribute it and/or modify it
  9.  * under the terms of the GNU Library General Public License as published 
  10.  * by the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23. #ifdef __PORTABLE_OBJC__
  24.  
  25. #ifndef __objcrt__
  26. #define __objcrt__
  27.  
  28. #include <stdio.h>  /* FILE */
  29. #include <stddef.h> /* size_t */
  30.  
  31. /* Pragmas for common builtin types and builtin functions */
  32.  
  33. #ifndef __LCC__
  34. #ifndef __WATCOMC__
  35. #ifndef __MWERKS__
  36. #ifndef __hpux
  37. #ifndef _WIN32
  38. #pragma OCbuiltInFctn __builtin_isfloat
  39. #pragma OCbuiltInFctn __builtin_classof
  40. #pragma OCbuiltInFctn __alignof__ /* sgi 5.2 gcc */
  41. #pragma OCbuiltInFctn __builtin_alignof 
  42. #pragma OCbuiltInFctn __builtin_next_arg
  43. #if 0
  44. #pragma OCbuiltInFctn __builtin_alloca
  45. #pragma OCbuiltInFctn __builtin_memcpy
  46. #endif
  47. #pragma OCbuiltInVar __PRETTY_FUNCTION__
  48. #pragma OCbuiltInVar _VA_FP_SAVE_AREA
  49. #endif
  50. #endif
  51. #endif
  52. #endif
  53. #endif
  54.  
  55. #ifndef EXPORT
  56. #define EXPORT /* empty */
  57. #endif
  58.  
  59. #ifndef EXTERNC
  60. #ifdef __cplusplus
  61. #define EXTERNC extern "C"
  62. #else
  63. #define EXTERNC 
  64. #endif
  65. #endif
  66.  
  67.  
  68. /* The "id" type is assumed to be defined by the compiler
  69.  * (in the case of objc or objcc, by emitting a typedef)
  70.  * This also allows for cross compiles with gcc in ObjC mode
  71.  * because a definition here would redefine its builtin "id".
  72.  */
  73.  
  74. /* The traditional Objective C types (see Brad Cox' book)
  75.  */
  76.  
  77. typedef char *SEL;    /* Uniqued String for Selector */
  78. typedef char *STR;    /* C, NULL-terminated, String */
  79. typedef char BOOL;    /* Boolean */
  80. typedef FILE *IOD;      /* I/O Device */
  81. typedef id SHR;         /* type of class, for us, it's id */
  82.  
  83. #ifdef __cplusplus
  84. typedef id (*IMP)(...);    /* Method pointer */
  85. #else
  86. typedef id (*IMP)();    /* Method pointer */
  87. #endif
  88.  
  89. typedef void (*ARGIMP)(id,SEL,void*); /* dispatcher */
  90.  
  91. /* The traditional Objective C defines 
  92.  */
  93.  
  94. #ifndef YES
  95. #define YES (BOOL)1 /* Boolean TRUE */
  96. #endif
  97.  
  98. #ifndef NO
  99. #define NO (BOOL)0 /* Boolean FALSE */
  100. #endif
  101.  
  102. #ifndef nil
  103. #define nil (id)0 /* id of Nil instance */
  104. #endif
  105.  
  106. /* C Messenger interface - try to be compatible */
  107.  
  108. /* msg tracing */
  109. extern BOOL msgFlag;     /* message tracing */
  110. extern FILE *msgIOD;     /* device for message tracing */
  111. extern FILE *dbgIOD;     /* device for dbg() call */
  112. extern BOOL allocFlag;   /* allocation tracing */
  113. extern BOOL dbgFlag;     /* verbose dbg() calls */
  114. extern BOOL noCacheFlag; /* disable messenger caching */
  115. extern BOOL noNilRcvr;   /* do not allow msg. to nil */
  116.  
  117. /* all in the name of backw. compat. */
  118. #ifndef NAMEOF
  119. #define NAMEOF(myObject) ([myObject name])
  120. #endif
  121.  
  122. SEL EXPORT selUid(STR);
  123. STR EXPORT selName(SEL);
  124. void EXPORT dbg(char *fmt, ...);
  125. void EXPORT prnstack(FILE *file);
  126. void EXPORT loadobjc(void *modPtr);
  127. void EXPORT unloadobjc(void *modPtr);
  128.  
  129.  
  130. /* our own (new) forwarding C messenger */
  131. EXTERNC IMP  EXPORT fwdimp(id,SEL,IMP);
  132. EXTERNC IMP  EXPORT fwdimpSuper(id,SEL,IMP);
  133. EXTERNC void EXPORT fwdmsg(id,SEL,void*,ARGIMP);
  134. EXTERNC id   EXPORT selptrfwd(id,SEL,id,id,id,id);
  135.  
  136. /* refcount functions */
  137. EXTERNC id EXPORT idincref(id obj);
  138. EXTERNC id EXPORT idassign(id *lhs,id rhs);
  139. EXTERNC id EXPORT iddecref(id obj);
  140.  
  141. extern id (*_fileIn)(FILE*);
  142. extern BOOL (*_fileOut)(FILE*,id);
  143. extern BOOL (*_storeOn)(STR,id);  
  144. extern id (*_readFrom)(STR);
  145. void EXPORT setfilein(id (*f)(FILE *));
  146. void EXPORT setfileout(BOOL (*f)(FILE *,id));
  147.  
  148. extern id (*_showOn)(id,unsigned); 
  149.  
  150. void EXPORT *OC_Malloc(size_t);
  151. void EXPORT *OC_MallocAtomic(size_t); 
  152. void EXPORT *OC_Calloc(size_t); 
  153. void EXPORT *OC_Realloc(void *,size_t); 
  154. void EXPORT *OC_Free(void *data); 
  155.  
  156. #endif /* __objcrt__ */
  157.  
  158. #endif /* __PORTABLE_OBJC__ */
  159.  
  160.  
  161.  
  162.